#ifndef SERIALIZABLE_H
#define SERIALIZABLE_H

#include <QObject>
#include <QMetaProperty>
#include "serializator.h"

namespace Core
{

class Serializable : public QObject
{
    Q_OBJECT
private:
    void deepCopy(const QObject& from, QObject* to)
    {
        for ( int i = 0; i < from.metaObject()->propertyCount(); i++ )
            to->metaObject()->property(i).write(to, from.metaObject()->property(i).read(&from));
    }

public:
    Serializable() : QObject()
    {

    }

    Serializable(const Serializable &other) : QObject()
    {
        deepCopy(other, this);
    }

    Serializable& operator=(const Serializable &other)
    {
        deepCopy(other, this);
        return *this;
    }

    virtual bool isValid() const = 0;
    virtual ObjectString toString() const = 0;
};

}

#endif // SERIALIZABLE_H
